<?php

/**
 * 订单支付流水模型
 *
 * Created by PhpStorm.
 * User: li
 * Date: 15-10-29
 * Time: 上午10:41
 */
class Order_serial extends MY_Model
{
    function __construct(){
        parent::__construct();
        $this->_table_name = 'serial';
    }

    function refund($serial_id,$order_id){
        $this->db->trans_start();
        $this->serial_refund($serial_id);
        $this->order_refund($order_id);
        $this->db->trans_complete();
    }
    private function serial_refund($serial_id){
        $this->db->where('id',$serial_id);
        $this->db->set('status',2);
        $this->db->update($this->_table_name);
    }
    private function order_refund($order_id){
        $this->db->where('order_id',$order_id);
        $this->db->set('status',7);
        $this->db->update('order');
    }

    function refund_stop($serial_id){
        $this->db->where('id',$serial_id);
        $this->db->set('status',0);
        $this->db->update($this->_table_name);
    }
}